Skip to content

fix(cli): surface stale-workspace registration error instead of fake "not a git repo"#1332

Merged
Wirasm merged 4 commits intodevfrom
fix/cli-stale-workspace-registration-error
Apr 22, 2026
Merged

fix(cli): surface stale-workspace registration error instead of fake "not a git repo"#1332
Wirasm merged 4 commits intodevfrom
fix/cli-stale-workspace-registration-error

Conversation

@Wirasm
Copy link
Copy Markdown
Collaborator

@Wirasm Wirasm commented Apr 21, 2026

Fresh re-do of #1157 (closed — draft + CONFLICTING, plus out-of-scope Windows test-compat changes mentioned in the body but not actually present). Full credit to @Bortlesboat via `Co-authored-by:`.

Problem (#1146)

`archon workflow run` (or `--resume`) runs from inside a perfectly valid git repo. Auto-registration kicks in, trips over a stale `~/.archon/workspaces///source` symlink that points at some old checkout, and `createProjectSourceSymlink()` in `@archon/paths` throws:

```
Source symlink at already points to , expected
```

The CLI caught that error, logged it at warn level, continued with `codebase = null`, and then the isolation / resume fallbacks threw:

```
Cannot create worktree: not in a git repository.
```

That message is wrong. The repo is fine — the Archon workspace entry is stale. It sends users hunting for missing `.git` dirs, checking git permissions, reinstalling git — all wasted effort.

Fix

  1. Preserve the registration error on a new `codebaseRegistrationError` local in `workflowRunCommand`.
  2. At both fallback sites (`--resume` and worktree-creation default), before the generic "not in a git repository" branch, check `codebaseRegistrationError` and throw a truthful error via a new `buildRegistrationFailureError(action, error)` helper:
    ```
    Cannot {create worktree,resume}: repository registration failed.
    Error:
    Hint: Remove the stale workspace entry at and retry,
    or use --no-worktree to skip isolation.
    ```
  3. The exact `` in the hint is computed by `extractStaleWorkspaceEntry()`, a tight parser bound to the known `"Source symlink at X already points to Y, expected Z"` shape. When the message doesn't match that shape (future error-text changes, wrapping, etc.), the parser returns `null` and the hint falls back to a generic `"check registration under /workspaces"`. Safe degradation — the error is still truthful, just less specific.
  4. Cross-platform path handling: `Math.max(lastIndexOf('/'), lastIndexOf('\\'))` so the parser handles Windows separators in the error text too.

Test

`packages/cli/src/commands/workflow.test.ts` — new regression test `surfaces auto-registration failures instead of claiming the repo is invalid`:

  • Mocks a `registerRepository` that rejects with the real `createProjectSourceSymlink` error shape
  • Asserts the thrown message contains `Cannot create worktree: repository registration failed.`
  • Asserts it contains `Remove the stale workspace entry at /home/test/.archon/workspaces/acme/widget and retry` (parser extracted the right dir)
  • Asserts the misleading `not in a git repository` string is not present

Validation

  • `bun run validate` green locally (type-check + lint + format:check + check:bundled + full test suite — 85 CLI tests pass including the new one)

Out of scope

The original #1157 body mentioned test-compat tweaks in `packages/paths/src/env-integration.test.ts` and `packages/core/src/providers/claude.test.ts` for Windows `Path` / `USERPROFILE` env keys, but those changes weren't actually in the diff. Left out of this re-do — if the Windows issue is still real, a follow-up PR is the right home for it.

Closes #1146.

Co-authored-by: Bortlesboat Bortlesboat@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes
    • CLI now reports “repository registration failed” for workflow run/resume when workspace symlinks are stale, and provides an actionable cleanup hint instead of a generic “not in a git repository” message.
  • Tests
    • Added tests verifying improved error messages and hint behavior for run, resume, malformed/unrecognized registration errors, and path extraction across platforms.
  • Documentation
    • Updated troubleshooting guidance to explain stale workspace symlinks and show the new error output with cleanup instructions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25128698-9148-4c71-9b57-15e5669d7549

📥 Commits

Reviewing files that changed from the base of the PR and between 28d007c and eb1cfca.

📒 Files selected for processing (1)
  • packages/cli/src/commands/workflow.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/cli/src/commands/workflow.test.ts

📝 Walkthrough

Walkthrough

The CLI now captures repository auto-registration failures caused by stale workspace source symlinks and rethrows them as "Cannot {create worktree,resume}: repository registration failed." with a targeted cleanup hint (pointing to the stale workspace path or the workspaces directory) instead of the previous generic "not in a git repository" message.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added a Fixed entry documenting corrected CLI diagnostics for stale workspace source-symlink registration failures.
CLI implementation
packages/cli/src/commands/workflow.ts
Added `extractStaleWorkspaceEntry(message: string): string
Tests
packages/cli/src/commands/workflow.test.ts
Added tests simulating stale workspace source-symlink failures for run and --resume flows asserting the new wrapped error messages and hints; added extractStaleWorkspaceEntry unit tests covering POSIX/Windows and malformed inputs.
Docs
packages/docs-web/src/content/docs/getting-started/overview.md
Updated Troubleshooting to show the new "Cannot create worktree…" output including the embedded stale-symlink error and a cleanup hint; adjusted guidance and wording to reflect the new messaging.

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant CLI as Archon CLI
  participant Reg as Repository Registration
  participant FS as Filesystem
  participant Git as Git detection
  User->>CLI: run `archon workflow run` (or `--resume`)
  CLI->>Reg: registerRepository(...) (auto-registration)
  Reg->>FS: check/create workspace `.../source` symlink
  FS-->>Reg: throws stale-symlink error (createProjectSourceSymlink shape)
  Reg-->>CLI: throws registration error
  CLI->>CLI: extractStaleWorkspaceEntry(error.message)
  CLI-->>User: "Cannot {create worktree,resume}: repository registration failed." + cleanup hint (stale path or workspaces dir)
  CLI->>Git: proceed to git detection only if registration succeeded
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
A crooked link hid in the loam,
I sniffed the trail and found its home.
"Remove the stale," my note will say,
Hop, clear the path, then run away—
New worktree blooms at break of day.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing the CLI to surface the true stale-workspace registration error instead of the misleading 'not a git repo' message.
Description check ✅ Passed The description provides a clear problem statement, explains the fix in detail with code examples, includes test validation results, notes out-of-scope decisions, and closes the linked issue. However, it omits some template sections (UX Journey, Architecture Diagram, Label Snapshot, Change Metadata, Security Impact, Compatibility, Human Verification, Side Effects, Rollback Plan, Risks and Mitigations).
Linked Issues check ✅ Passed The PR fully addresses issue #1146: it surfaces the real auto-registration error instead of the misleading 'not in a git repository' message, provides actionable recovery hints (remove stale workspace entry), ensures cross-platform path handling, and includes regression tests covering both worktree and resume paths.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the stale-workspace registration error: CLI error handling, a parser function, test coverage, changelog entry, and documentation update. The PR explicitly excludes the unrelated Windows test-compat tweaks mentioned in the prior #1157, maintaining clear scope boundaries.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-stale-workspace-registration-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/workflow.ts`:
- Around line 116-124: buildRegistrationFailureError currently calls
getArchonHome() unguarded which can throw and mask the original registration
error; change it to compute the fallback path inside a try/catch and only
include the home-based hint if getArchonHome() succeeds, otherwise fall back to
a safe generic hint that does not call getArchonHome() or throw; ensure the
returned Error always contains the original error.message and never replaces it
with a secondary home-resolution error (refer to buildRegistrationFailureError,
getArchonHome, extractStaleWorkspaceEntry).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8c095d7b-ffd9-4c98-942c-10b328ca351e

📥 Commits

Reviewing files that changed from the base of the PR and between ba4b9b4 and f12e3ff.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts

Comment thread packages/cli/src/commands/workflow.ts
@Wirasm
Copy link
Copy Markdown
Collaborator Author

Wirasm commented Apr 22, 2026

Multi-Agent Review Summary — PR #1332

Five specialist agents reviewed the diff. Scope: 3 files (~96 LoC), one focused CLI error-classification change plus test and CHANGELOG.

Verdict: NEEDS FIXES (non-blocking)

No critical issues. One meaningful behavioral gap (untested resume-path wiring) and one stale docs page that undermines the fix's user-facing value. Otherwise the change is clean.


Critical Issues (0)

None.

Important Issues (3)

# Agent Finding Location
I1 pr-test-analyzer Resume-path wiring is untested (9/10). The PR adds symmetric guards at two fallback sites (worktree-create + resume). Only the worktree path has a regression test. If the resume guard is accidentally deleted or inverted, no test fails. packages/cli/src/commands/workflow.ts:437-440
I2 pr-test-analyzer buildRegistrationFailureError null-fallback branch untested (8/10). When extractStaleWorkspaceEntry returns null (any non-createProjectSourceSymlink error), the generic hint path is taken. Inverting the ternary would go undetected. packages/cli/src/commands/workflow.ts:117-127
I3 docs-impact Stale troubleshooting page. The docs entry is keyed on the OLD misleading error string — after this PR, users hitting the stale-symlink case will never see that text and so will never find the fix. packages/docs-web/src/content/docs/getting-started/overview.md:485-495

Suggestions (4)

# Agent Suggestion Location
S1 pr-test-analyzer Add direct parser-edge-case tests (Windows separators, missing delimiter, no-separator path). Low priority — the safe fallback makes bugs non-critical — but worth it since helpers are non-exported and the claim of Windows support is currently unverified. workflow.ts:93-106
S2 code-reviewer extractStaleWorkspaceEntry is not exported; exporting it would allow direct unit tests for the lastSeparator === -1 guard and Windows path handling (covers S1 + I2 at lower test cost). workflow.ts
S3 comment-analyzer Trim extractStaleWorkspaceEntry docblock. Only the embedded error-string literal (cross-package contract with @archon/paths) is load-bearing; the separator and null-return descriptions narrate what the code already shows. workflow.ts (new docblock)
S4 comment-analyzer buildRegistrationFailureError docblock's second paragraph ("Before this helper existed…") is PR-description / CHANGELOG material, not a durable function contract. The See #1146 reference and the (#1146) suffix on the test-file section divider are similarly PR-description prose. workflow.ts, workflow.test.ts

Strengths

  • Parser binding verified correct. The literal parsed by extractStaleWorkspaceEntry ("Source symlink at <linkPath> already points to <existing>, expected <target>") matches the exact throw site at packages/paths/src/archon-paths.ts:421. Owner/repo are constrained by SAFE_NAME = /^[a-zA-Z0-9._-]+$/, so the " already points to " delimiter can never appear inside linkPath.
  • No silent failures. Original warn log preserved; original error.message embedded verbatim in all re-thrown messages regardless of parse outcome; codebaseRegistrationError variable liveness clean (single write, two reads, no overwrite window).
  • Negative assertion in the one test is exactly right. expect(error.message).not.toContain('not in a git repository') pins the fix, not just the new behavior.
  • codebaseLookupError vs codebaseRegistrationError cleanly separated — the two error classes have independent fallback sites and hints.
  • No project-guideline violations. Typed imports, no any, logging follows domain.action_state, KISS/YAGNI respected.

Out-of-Scope Observations (not blocking)

Recommended Actions (in order)

  1. Add a resume-path regression test mirroring the worktree test (I1).
  2. Add a test for the null-parser fallback hint (I2) — or better, export extractStaleWorkspaceEntry and table-test it (S2 covers I2 + S1).
  3. Update the troubleshooting docs page to key on the new error string (I3).
  4. Trim the two docblocks and drop the #1146 references (S3, S4).

Multi-agent review: code-reviewer, pr-test-analyzer, silent-failure-hunter, comment-analyzer, docs-impact (parallel).

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/cli/src/commands/workflow.test.ts (1)

868-973: New regression coverage looks solid.

Worktree-path, resume-path, and unrecognized-shape fallback are all exercised, the negative assertions correctly track the "not in a git repository" / "Not in a git repository" casing in the two throw sites, and mocks stay within the existing process-global mock.module() pattern (no mock.restore() misuse introduced).

One optional follow-up (non-blocking): the parser itself (extractStaleWorkspaceEntry) is only tested indirectly through workflowRunCommand. If you want cheap coverage for Windows separators, missing delimiter, and no-separator inputs, export it from ./workflow and table-test it directly — otherwise those branches will only break loudly if the main integration paths happen to exercise them.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/workflow.test.ts` around lines 868 - 973, The tests
only exercise extractStaleWorkspaceEntry indirectly via workflowRunCommand;
export extractStaleWorkspaceEntry from ./workflow and add targeted unit tests
that table-drive Windows path separators, inputs missing the expected delimiter,
and inputs with no separator to cover those branches directly (create tests
referencing extractStaleWorkspaceEntry so failures are pinpointed rather than
relying on the larger integration flow).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/docs-web/src/content/docs/getting-started/overview.md`:
- Around line 489-493: Add a language identifier to the fenced code block
containing the "Cannot create worktree: repository registration failed." example
by changing the opening fence from ``` to ```text so the block is fenced as
```text; locate the block that begins with the exact text "Cannot create
worktree: repository registration failed." in overview.md and update only the
opening fence to include "text" (no other content changes).

---

Nitpick comments:
In `@packages/cli/src/commands/workflow.test.ts`:
- Around line 868-973: The tests only exercise extractStaleWorkspaceEntry
indirectly via workflowRunCommand; export extractStaleWorkspaceEntry from
./workflow and add targeted unit tests that table-drive Windows path separators,
inputs missing the expected delimiter, and inputs with no separator to cover
those branches directly (create tests referencing extractStaleWorkspaceEntry so
failures are pinpointed rather than relying on the larger integration flow).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a9c23b96-b232-4c6c-8769-6dcc192d0fce

📥 Commits

Reviewing files that changed from the base of the PR and between f12e3ff and f32f002.

📒 Files selected for processing (3)
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts
  • packages/docs-web/src/content/docs/getting-started/overview.md

Comment on lines 489 to 493
```
Source symlink at ~/.archon/workspaces/.../source already points to <old-path>, expected <new-path>
Cannot create worktree: repository registration failed.
Error: Source symlink at ~/.archon/workspaces/<owner>/<repo>/source already points to <old-path>, expected <new-path>
Hint: Remove the stale workspace entry at ~/.archon/workspaces/<owner>/<repo> and retry, or use --no-worktree to skip isolation.
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language to the fenced code block.

Static analysis (markdownlint-cli2 MD040) flags the example block as missing a language identifier. Use text (or similar) so the CI lint stays clean and the code fence gets consistent rendering with the rest of the doc.

📝 Proposed fix
-```
+```text
 Cannot create worktree: repository registration failed.
 Error: Source symlink at ~/.archon/workspaces/<owner>/<repo>/source already points to <old-path>, expected <new-path>
 Hint: Remove the stale workspace entry at ~/.archon/workspaces/<owner>/<repo> and retry, or use --no-worktree to skip isolation.
</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.22.0)</summary>

[warning] 489-489: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @packages/docs-web/src/content/docs/getting-started/overview.md around lines
489 - 493, Add a language identifier to the fenced code block containing the
"Cannot create worktree: repository registration failed." example by changing
the opening fence from totext so the block is fenced as ```text; locate
the block that begins with the exact text "Cannot create worktree: repository
registration failed." in overview.md and update only the opening fence to
include "text" (no other content changes).


</details>

<!-- fingerprinting:phantom:medusa:nectarine:40625e77-8497-433d-a84f-91a7b1f27590 -->

<!-- This is an auto-generated comment by CodeRabbit -->

Wirasm and others added 3 commits April 22, 2026 12:06
…"not a git repo"

When workflowRunCommand auto-registers an unregistered repo, a stale
~/.archon/workspaces/<owner>/<repo>/source symlink (pointing to an old
checkout) causes createProjectSourceSymlink() in @archon/paths to throw:

  Source symlink at <linkPath> already points to <existing>, expected <target>

The CLI caught that in a try/catch, logged it at warn level, continued
with `codebase = null`, and then the isolation / resume branches hit
their "codebase missing" fallback and threw the generic:

  Cannot create worktree: not in a git repository.

That message is false — the repo is valid; the Archon workspace entry
is stale. It sends users down the wrong diagnostic path (checking git
config, permissions, etc.) instead of pointing at the workspace dir.

Fix: preserve the registration error on a new `codebaseRegistrationError`
local, and at both fallback sites (resume + worktree-creation) check it
before the generic "not a git repo" branch. When set, throw a truthful:

  Cannot {create worktree,resume}: repository registration failed.
  Error: <original message>
  Hint: Remove the stale workspace entry at <dir> and retry, or
        use --no-worktree to skip isolation.

The hint's exact path comes from a small parser that extracts the
workspace directory from the known "Source symlink at …" format; when
the message shape doesn't match (future error text changes), the parser
returns null and we fall back to a generic "check registration under
<archon-home>/workspaces" hint — safe degradation.

Regression test in workflow.test.ts asserts the new error message and
negatively asserts the old "not in a git repository" string is gone.

Supersedes #1157 — that PR was draft + CONFLICTING against current dev,
and also mentioned Windows test-compat changes that weren't in the diff
(pruned scope). This is a fresh re-do focused strictly on #1146.

Closes #1146.

Co-authored-by: Bortlesboat <Bortlesboat@users.noreply.github.com>
…ing docs

Addresses multi-agent review feedback on this PR:

- Add regression test for the --resume fallback site (the worktree-create
  site was already covered; the resume site had identical wiring but zero
  test coverage).
- Add test for the unrecognized-error-shape branch of
  buildRegistrationFailureError so the generic workspace hint is pinned
  (prevents accidental inversion of the stale-entry vs generic-hint
  ternary).
- Update the troubleshooting page to key on the new
  "Cannot create worktree: repository registration failed." message.
  Users hitting the new error won't find the page under the old heading,
  and the "In the future..." note is obsolete now that the error itself
  contains the cleanup path.
- Trim both new docblocks: keep the load-bearing cross-package error
  string contract in extractStaleWorkspaceEntry, drop narration of what
  the code already shows. Drop the "Before this helper existed..."
  paragraph from buildRegistrationFailureError — that's CHANGELOG
  material. Drop PR-reference suffix from the test section divider.
Two follow-up fixes to the multi-agent review commit (f32f002):

CodeRabbit finding — unguarded getArchonHome() in the fallback hint.
If getArchonHome() ever throws (misconfigured env vars, permission issues
on the resolution path), the registration-failure Error would never get
constructed: we'd throw a secondary home-resolution error that masks the
root cause. Wrap the fallback branch in try/catch — prefer losing the
exact path in the hint over replacing the actionable registration error.
A safe generic hint ("Check your Archon workspace registration and retry")
takes over when getArchonHome() throws. The original error.message is
always embedded verbatim in the re-thrown Error.

S2 — export extractStaleWorkspaceEntry for direct table tests. The parser
is where the cross-package string contract with @archon/paths actually
lives; direct tests against it are cheaper than end-to-end CLI tests and
pin the edge cases:

- POSIX path with forward slashes (typical unix user)
- Windows path with backslashes (verifies Math.max(lastIndexOf / , lastIndexOf \))
- Unrelated error message (no prefix) → null
- Prefix matches but delimiter missing → null
- Source path without any separator → null (guards against returning
  empty string, which would produce a nonsense "Remove the stale
  workspace entry at " hint)
- Empty string → null

Six new cases in the test file. The claim of Windows support in the
PR description is now actually verified.
@Wirasm Wirasm force-pushed the fix/cli-stale-workspace-registration-error branch from f32f002 to 28d007c Compare April 22, 2026 09:07
@Wirasm
Copy link
Copy Markdown
Collaborator Author

Wirasm commented Apr 22, 2026

Pushed `28d007cf` (review-response f32f002 from yesterday + new commit c18ce3ce today) and rebased on current `dev` — CHANGELOG conflict resolved.

Important (3/3)

  • I1 — resume-path regression test ✅ (in f32f002)
    Resume fallback site now has its own test mirroring the worktree-create test.

  • I2 — null-fallback coverage ✅ (in c18ce3ce)
    Exported `extractStaleWorkspaceEntry` (per S2) and added direct table tests for the null branches (missing prefix, missing delimiter, no separator in source path, empty string). The `buildRegistrationFailureError` ternary's generic-hint branch is now pinned — inverting it would fail one of the new tests.

  • I3 — troubleshooting docs ✅ (in f32f002)
    Updated `getting-started/overview.md` to key on the new `"Cannot create worktree: repository registration failed."` message.

CodeRabbit (1/1)

  • Unguarded `getArchonHome()` in the fallback hint ✅ (in c18ce3ce)
    Wrapped in try/catch. If `getArchonHome()` ever throws (misconfigured env vars, permission weirdness), we fall back to a safe generic hint ("Check your Archon workspace registration and retry") rather than replacing the actionable registration error with a secondary home-resolution error. The original `error.message` is always embedded verbatim in the re-thrown Error.

Suggestions

ID Status
S1 (Windows separator + edge-case tests) ✅ covered by the new `extractStaleWorkspaceEntry` tests (POSIX, Windows backslash, no-separator, empty string)
S2 (export helper) ✅ in c18ce3ce
S3 (trim docblock narration) ✅ (in f32f002)
S4 (drop PR-ref prose from docblock / test divider) ✅ (in f32f002)
C1 (pre-existing resume/approve/reject `working_path`-as-cwd limitation) ⚪ deferred — confirmed out of scope for #1146 (that scenario is fresh `archon workflow run` at repo root, this scenario is the stored worktree path). Worth a separate issue.

`bun run validate` green locally; 93 CLI tests pass (6 new `extractStaleWorkspaceEntry` direct tests + 2 resume/null-fallback integration tests from the prior review commit).

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/cli/src/commands/workflow.test.ts (1)

2525-2567: Parser edge-case coverage looks solid.

Good coverage of POSIX, Windows backslash separators, unrelated error prefix, missing delimiter (truncated), no-separator path, and empty-string inputs — matches the four early-return branches in extractStaleWorkspaceEntry. Exporting the parser and table-testing it here is exactly what S1/S2 asked for.

Minor nit (optional): the repeated const { extractStaleWorkspaceEntry } = await import('./workflow'); inside every it() could be hoisted to a beforeAll or a top-level let since the module mocks are process-global — not a correctness issue.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/workflow.test.ts` around lines 2525 - 2567, Tests
repeatedly import extractStaleWorkspaceEntry inside each it() which is
redundant; hoist the import once to avoid repetition by moving the dynamic
import into a beforeAll or by declaring a top-level let and assigning it in a
single beforeAll, referencing the function name extractStaleWorkspaceEntry and
the test suite describe('extractStaleWorkspaceEntry', ...) so all specs reuse
the same imported symbol without repeated await import calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/cli/src/commands/workflow.test.ts`:
- Around line 2525-2567: Tests repeatedly import extractStaleWorkspaceEntry
inside each it() which is redundant; hoist the import once to avoid repetition
by moving the dynamic import into a beforeAll or by declaring a top-level let
and assigning it in a single beforeAll, referencing the function name
extractStaleWorkspaceEntry and the test suite
describe('extractStaleWorkspaceEntry', ...) so all specs reuse the same imported
symbol without repeated await import calls.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea6fc43f-78d1-4e29-a4f0-a04d414f2ea0

📥 Commits

Reviewing files that changed from the base of the PR and between f32f002 and 28d007c.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/cli/src/commands/workflow.test.ts
  • packages/cli/src/commands/workflow.ts
  • packages/docs-web/src/content/docs/getting-started/overview.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG.md
  • packages/cli/src/commands/workflow.ts

Windows test runner (CI) hit:
  Expected to contain: "Check your Archon workspace registration under /home/test/.archon/workspaces"
  Received: "... under \home\test\.archon\workspaces and retry, ..."

path.join normalizes to `\` on Windows and `/` on POSIX. The test hardcoded
forward slashes in the expected substring. Split into two separator-agnostic
asserts: the prefix up to "under", then `/workspaces\b/` regex for the final
path segment. Behavior doesn't change — the hint still gets the full
path.join'd workspaces dir on either platform.
@Wirasm Wirasm merged commit 056707d into dev Apr 22, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale workspace registration causes unrecoverable cli.codebase_auto_registration_failed with misleading secondary error

1 participant